package com.haoze.nurse.dao;

import com.haoze.common.model.OrdersFileIndexEntity;
import com.haoze.nurse.model.NurseFileDataEntity;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;
import java.util.Map;

public interface NurseFileDataMapper {

    /**
     * 获取某人指定类型指定时刻的记录
     * @param recordType
     * @param inpatNum
     * @param recordTime
     * @param careType 0 一般记录，1 出入量总结记录
     * @return
     */
    NurseFileDataEntity querySameTimeRecord(@Param("recordType") String recordType,
                                            @Param("inpatNum") String inpatNum,
                                            @Param("recordTime") String recordTime,
                                            @Param("careType") String careType);

    /**
     * 插入一条记录
     * @param nurseFileDataEntity
     * @return
     */
    int insert(NurseFileDataEntity nurseFileDataEntity);


    /**
     * 分页批量获取指定人指定类型记录
     * @param startNum
     * @param endNum
     * @param inpatNum
     * @param recordType
     * @param beginTime
     * @param endTime
     * @param recordTimeOrderType 1 正序 2倒序
     * @return
     */
    List<NurseFileDataEntity> queryDataList(@Param("startNum") Integer startNum,
                                            @Param("endNum") Integer endNum,
                                            @Param("inpatNum") String inpatNum,
                                            @Param("recordType") String recordType,
                                            @Param("beginTime") String beginTime,
                                            @Param("endTime") String endTime,
                                            @Param("recordTimeOrderType") String recordTimeOrderType
    );

    /**
     * 分页批量获取指定人指定类型打印记录
     * @param startNum
     * @param endNum
     * @param inpatNum
     * @param recordType
     * @return
     */
    List<NurseFileDataEntity> queryPrintDataList(@Param("startNum") Integer startNum,
                                                 @Param("endNum") Integer endNum,
                                                 @Param("inpatNum") String inpatNum,
                                                 @Param("recordType") String recordType,
                                                 @Param("beginTime") String beginTime,
                                                 @Param("endTime") String endTime);

    /**
     * 获取指定人指定类型记录总量
     * @param inpatNum
     * @param recordType
     * @param inpatNum
     * @return
     */
    int queryDataListSum(@Param("inpatNum") String inpatNum,
                         @Param("recordType") String recordType,
                         @Param("beginTime") String beginTime,
                         @Param("endTime") String endTime);

    /**
     * 删除记录
     * @param fileDataId
     * @return
     */
    int deleteDataRecord(@Param("fileDataId") String fileDataId);

    /**
     * 查询一条记录
     * @param fileDataId
     * @return
     */
    NurseFileDataEntity queryOneDataRecord(@Param("fileDataId") String fileDataId);

    int update(NurseFileDataEntity fileDataEntity);

    // 对于产时二和中期妊娠引产获取患者唯一记录
    NurseFileDataEntity queryOnlyRecord(@Param("recordType") String recordType,
                                        @Param("inpatNum") String inpatNum);

    /**
     * 查询时间范围内的参与统计的记录
     * @param inpatNum
     * @param recordType
     * @param beginTime
     * @param endTime
     * @return
     */
    List<NurseFileDataEntity> queryStatisticsDatas(@Param("inpatNum") String inpatNum,
                                                   @Param("recordType") String recordType,
                                                   @Param("beginTime") Date beginTime,
                                                   @Param("endTime") Date endTime);

    /**
     * 删除列表记录并且删除和其绑定的统计记录
     * @param statisticsId
     * @param fileDataId
     * @return
     */
    int deleteDataRecordAndStatistics(@Param("fileDataId") String fileDataId,
                                      @Param("statisticsId") String statisticsId);

    /**
     * 查询时间最近最后一条记录
     * @param inpatNum
     * @param recordTime
     * @param recordType
     * @return
     */
    NurseFileDataEntity queryLastData(@Param("inpatNum") String inpatNum,
                                      @Param("recordTime") String recordTime,
                                      @Param("recordType") String recordType);

    Map<String, String> queryDeptNameInfo(@Param("wardId") String wardId,
                                          @Param("deptId") String deptId,
                                          @Param("inpatNum") String inpatNum);

    int deleteStaticsDetail(@Param("statisticsId") String statisticsId);

    int deleteStatics(@Param("statisticsId") String statisticsId);

    String querySummaryRecord(@Param("inpatNum") String inpatNum,
                              @Param("recordType") String recordType,
                              @Param("recordTime") String recordTime);

    Map isSummary(Map<String, String> map);



    OrdersFileIndexEntity queryEmrFileIdByInpatNum(@Param("inpatNum") String inpatNum, @Param("tplId") String tplId);
}
